package com.gxa.ssm340.service.impl;

import com.gxa.ssm340.common.ErrorCode;
import com.gxa.ssm340.entity.dto.AllExchangeListDTO;
import com.gxa.ssm340.entity.dto.CpnDTO;
import com.gxa.ssm340.entity.dto.UpDownDTO;
import com.gxa.ssm340.entity.pojo.Coupon1;
import com.gxa.ssm340.entity.vo.AllExchangeVO;
import com.gxa.ssm340.exception.BizException;
import com.gxa.ssm340.mapper.CouponMapper;
import com.gxa.ssm340.service.CouponService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CouponServiceImpl implements CouponService {
    @Autowired
    private CouponMapper couponMapper;
    @Override
    public List<Coupon1> selectCouponAll(CpnDTO cpnDTO) {
        List<Coupon1> coupons = couponMapper.selectCouponAll(cpnDTO);
        return coupons;
    }

    @Override
    public Integer selectCouponAllCount() {
        Integer integer = couponMapper.selectCouponAllCount();
        return integer;
    }

    @Override
    public Integer insertCoupon(Coupon1 coupon) throws BizException {
        if (coupon==null){
            throw new BizException(ErrorCode.NULL_FIELD);
        }
        couponMapper.insertCoupon(coupon);
        return null;
    }

    @Override
    public Integer updateUpAndDown(UpDownDTO upDownDTO) throws BizException {
        if (upDownDTO==null){
            throw new BizException(ErrorCode.NULL_FIELD);
        }
        couponMapper.updateUpAndDown(upDownDTO);
        return null;
    }

    @Override
    public Integer delete(Integer id) throws BizException {
        couponMapper.delete(id);
        return null;
    }

    @Override
    public List<AllExchangeVO> AllExchangeList(AllExchangeListDTO dto) throws BizException {
        List<AllExchangeVO> allExchangeVOS = couponMapper.allExchangeList(dto);
        return allExchangeVOS;
    }


}
